package com.huang.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.huang.mapper.RoleMapper;
import com.huang.mapper.UserMapper;
import com.huang.pojo.Role;
import com.huang.pojo.User;
import com.huang.pojo.UserExample;
import com.huang.utils.ToListInt;
import com.huang.vo.PageResult;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class LoginService {
    @Resource
    private UserMapper userMapper;
    @Resource
    private RoleMapper roleMapper;

    /**
     * 根据用户名和密码登录
     * @param user
     * @return
     */
    public User loginByUserNameAndPassD(User user){
        UserExample userExample = new UserExample();
        UserExample.Criteria criteria = userExample.createCriteria();
        criteria.andU_loginNameEqualTo(user.getU_loginName());
        criteria.andU_passWordEqualTo(user.getU_passWord());
        criteria.andIsDelEqualTo(0);
        List<User> users = userMapper.selectByExample(userExample);
        if(users.size() == 0) {
            return null;
        } else {
            return users.get(0);
        }
    }


}
